package com.xm.xmapp;

import java.util.ArrayList;

import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.LinearLayout;

import com.xm.xmapp.adapter.RollViewPager;
import com.xm.xmapp.adapter.RollViewPager.OnPagerClickCallback;
import com.xm.xmapp.base.BaseActivity;
import com.xm.xmapp.tools.Options;
import com.xm.xmapp.tools.ScreenUtils;
import com.xm.xmapp.tools.Tools;

public class PanoramaActivity extends BaseActivity {
	private ArrayList<String> imgs;
	private LinearLayout scene_ad, dotLl;
	private RollViewPager viewPager;
	private ArrayList<View> dotList;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_panorama);
	}

	@Override
	public void initView() {
		scene_ad = (LinearLayout) findViewById(R.id.scene_ad);
		dotLl = (LinearLayout) findViewById(R.id.dots_ll);
	}

	@Override
	public void initData() {
		setMyTitle("网点照片");
		imgs = getIntent().getStringArrayListExtra("imgs");
		dotList = new ArrayList<View>();
		dotLl.removeAllViews();
		int size = imgs.size();
		for (int i = 0; i < size; i++) {
			LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(Tools.dp2px(10), Tools.dp2px(10));
			params.setMargins(Tools.dp2px(5), 0, Tools.dp2px(5), 0);
			View m = new View(this);
			if (i == 0) {
				m.setBackgroundResource(R.mipmap.panoramicview_icon_press);
			} else {
				m.setBackgroundResource(R.mipmap.panoramicview_icon_normal);
			}
			m.setLayoutParams(params);
			dotLl.addView(m);
			dotList.add(m);
		}
		LayoutParams laParams = (LayoutParams) scene_ad.getLayoutParams();
		laParams.width = ScreenUtils.getScreenWidth(this);
		laParams.height = ScreenUtils.getScreenHeight(this) - Tools.dp2px(50);// 减去标题栏的高度
		scene_ad.setLayoutParams(laParams);
		viewPager = new RollViewPager(this, dotList, R.mipmap.panoramicview_icon_press,
				R.mipmap.panoramicview_icon_normal, new OnPagerClickCallback() {
					@Override
					public void onPagerClick(int position) {
					}
				});
		viewPager.setOptions(Options.getListOptions(R.mipmap.panoramicview_img_photo));
		viewPager.setUriList(imgs);
		viewPager.startRoll();
		scene_ad.removeAllViews();
		scene_ad.addView(viewPager);
		viewPager.setCurrentItem(0);

	}

	@Override
	public void initEvent() {

	}

}
